import akshare as ak
import requests


def get_fund_data(code):
    url = f"https://danjuanfunds.com/djapi/fund/{code}"
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
        "Chrome/80.0.3987.149 Safari/537.36"
    }
    r = requests.get(url, headers=headers)
    json_data = r.json()["data"]
    return {
        "fund_code": json_data['fd_code'],
        "fund_name": json_data['fd_name']
    }


# columns={
#             "fd_code": "基金代码",
#             "fd_name": "基金名称",
#             "fd_full_name": "基金全称",
#             "found_date": "成立时间",
#             "totshare": "最新规模",
#             "keeper_name": "基金公司",
#             "manager_name": "基金经理",
#             "trup_name": "托管银行",
#             "type_desc": "基金类型",
#             "rating_source": "评级机构",
#             "rating_desc": "基金评级",
#             "invest_orientation": "投资策略",
#             "invest_target": "投资目标",
#             "performance_bench_mark": "业绩比较基准",
#         },

# ak.fund_individual_basic_info_xq
# print(get_fund_data('519674'))

